package com.njit.farm.controller;

import com.njit.farm.model.ReapedPlant;
import com.njit.farm.model.ReapedPlantState;
import com.njit.farm.model.Result;
import com.njit.farm.service.ReapedPlantService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/reapedPlant/")
public class ReapedPlantController {

    @Resource
    ReapedPlantService reapedPlantService;

    @RequestMapping(value = "add",method = RequestMethod.POST)
    public Result add(@RequestBody ReapedPlant reapedPlant){

        return reapedPlantService.add(reapedPlant);
    }

    @RequestMapping(value = "getByUserId", method = RequestMethod.GET)
    public Result getByUserId(@RequestParam String uId) {

        return reapedPlantService.queryByUserId(uId);
    }

    @RequestMapping(value = "update", method = RequestMethod.POST)
    public Result update(@RequestBody ReapedPlant reapedPlant){
        return reapedPlantService.update(reapedPlant);
    }
}
